/*
Run this script on:

        mssql-ct.db.jwan.it,1433.Caronte2013    -  This database will be modified

to synchronize it with:

        kalgan01.cs.jwan.it,1443.Jambo2014_sviluppo

You are recommended to back up your database before running this script

Script created by SQL Compare version 9.0.0 from Red Gate Software Ltd at 10/04/2014 10:17:12

*/
SET NUMERIC_ROUNDABORT OFF
GO
SET ANSI_PADDING, ANSI_WARNINGS, CONCAT_NULL_YIELDS_NULL, ARITHABORT, QUOTED_IDENTIFIER, ANSI_NULLS ON
GO
IF EXISTS (SELECT * FROM tempdb..sysobjects WHERE id=OBJECT_ID('tempdb..#tmpErrors')) DROP TABLE #tmpErrors
GO
CREATE TABLE #tmpErrors (Error int)
GO
SET XACT_ABORT ON
GO
SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
GO
BEGIN TRANSACTION
GO
PRINT N'Creating [dbo].[dettax_iva_arch]'
GO
CREATE TABLE [dbo].[dettax_iva_arch]
(
[CODPREN] [char] (14) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[N_SEQ] [int] NOT NULL,
[N_MOD] [int] NOT NULL,
[ALIQUOTA] [decimal] (18, 2) NOT NULL,
[CODIVA] [char] (3) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[CODTASSA] [varchar] (4) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[IMPORTO] [decimal] (18, 2) NOT NULL
)
GO
IF @@ERROR<>0 AND @@TRANCOUNT>0 ROLLBACK TRANSACTION
GO
IF @@TRANCOUNT=0 BEGIN INSERT INTO #tmpErrors (Error) SELECT 1 BEGIN TRANSACTION END
GO
PRINT N'Creating [dbo].[dettax_iva]'
GO
CREATE TABLE [dbo].[dettax_iva]
(
[CODPREN] [char] (14) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[N_SEQ] [int] NOT NULL,
[N_MOD] [int] NOT NULL,
[ALIQUOTA] [decimal] (18, 2) NOT NULL,
[CODIVA] [char] (3) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[CODTASSA] [varchar] (4) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[IMPORTO] [decimal] (18, 2) NOT NULL
)
GO
IF @@ERROR<>0 AND @@TRANCOUNT>0 ROLLBACK TRANSACTION
GO
IF @@TRANCOUNT=0 BEGIN INSERT INTO #tmpErrors (Error) SELECT 1 BEGIN TRANSACTION END
GO
PRINT N'Creating primary key [PK_dettax_iva] on [dbo].[dettax_iva]'
GO
ALTER TABLE [dbo].[dettax_iva] ADD CONSTRAINT [PK_dettax_iva] PRIMARY KEY CLUSTERED  ([CODPREN], [N_SEQ], [N_MOD], [ALIQUOTA], [CODIVA], [CODTASSA])
GO
IF @@ERROR<>0 AND @@TRANCOUNT>0 ROLLBACK TRANSACTION
GO
IF @@TRANCOUNT=0 BEGIN INSERT INTO #tmpErrors (Error) SELECT 1 BEGIN TRANSACTION END
GO
PRINT N'Altering permissions on [dbo].[dettax_iva]'
GO
GRANT SELECT ON  [dbo].[dettax_iva] TO [JamboClient]
GRANT DELETE ON  [dbo].[dettax_iva] TO [JamboClient]
GO
PRINT N'Altering permissions on [dbo].[dettax_iva_arch]'
GO
GRANT SELECT ON  [dbo].[dettax_iva_arch] TO [JamboClient]
GO
IF EXISTS (SELECT * FROM #tmpErrors) ROLLBACK TRANSACTION
GO
IF @@TRANCOUNT>0 BEGIN
PRINT 'The database update succeeded'
COMMIT TRANSACTION
END
ELSE PRINT 'The database update failed'
GO
DROP TABLE #tmpErrors
GO
